file = open("students.txt", encoding="utf-8")

lines = file.readlines()
for line in lines:
    print(line.strip())
    # print(line.rstrip())
    # print(line.lstrip())

#  readlines  知道有第一次能读到数据
# print(file.readlines())


# 去掉前后空格
lines = [line.strip() for line in lines]

print(lines)

#  mode = w  输出流
file2 = open("a.txt", encoding="utf-8", mode="w")

for line in lines:
    file2.write(line)
    file2.write("\n")

file2.close()

#  自动关闭
with open("students.txt", encoding="utf-8") as f:
    print(f.readlines())

import json

js = json.loads('{"id":"1500100003","name":"单乐蕊","age":22,"gender":"女","clazz":"理科六班"}')

print(js["id"])
print(js["name"])
print(js["age"])
print(js["gender"])


